package com.zwj.controller;


import com.zwj.bo.CourseNodeBo;
import com.zwj.dto.Result;
import com.zwj.entity.CourseNodeEntity;
import com.zwj.service.CourseNodeService;
import com.zwj.utils.TokenUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zwj
 * @since 2021-11-02
 */
@RestController
@RequestMapping("/courseNode")
public class CourseNodeController {
    private final CourseNodeService CourseNodeService;
    public CourseNodeController(CourseNodeService CourseNodeService) {
        this.CourseNodeService = CourseNodeService;
    }
    @ApiOperation(value = "条件查询章节", notes = "条件查询章节")
    @PostMapping("/selectCourseNode")
    public Result selectCourseNode(@RequestBody CourseNodeBo courseNodeBo) {
        return CourseNodeService.selectCourseNode(courseNodeBo);
    }
    @ApiOperation(value = "删除章节", notes = "删除章节")
    @PostMapping("/deleteCourseNode")
    public Result deleteCourseNode(@RequestBody CourseNodeBo courseNodeBo) {
        return CourseNodeService.deleteCourseNode(courseNodeBo);
    }
    @ApiOperation(value = "添加章节", notes = "添加章节")
    @PostMapping("/addCourseNode")
    public Result addCourseNode(@RequestBody CourseNodeEntity courseNodeEntity, HttpServletRequest httpServletRequest) {
        String userId = TokenUtils.getUserID(httpServletRequest);
        return CourseNodeService.addCourseNode(courseNodeEntity,userId);
    }
    @ApiOperation(value = "修改章节信息", notes = "修改章节信息")
    @PostMapping("/updateCourseNode")
    public Result updateCourseNode(@RequestBody CourseNodeEntity courseNodeEntity, HttpServletRequest httpServletRequest) {
        String userId = TokenUtils.getUserID(httpServletRequest);
        return CourseNodeService.updateCourseNode(courseNodeEntity,userId);
    }
    @ApiOperation(value = "通过ID查询章节", notes = "通过ID查询章节")
    @PostMapping("/selectCourseNodeById")
    public Result selectCourseNodeById(@RequestBody CourseNodeBo courseNodeBo) {
        return CourseNodeService.selectCourseNodeById(courseNodeBo);
    }
}

